const app =new Vue({
    el:"#app",
    data(){
        return{
            barbecue:[
                {
                    name:"寿司",
                    id:1,
                    images:'./images/img1.jpg',
                    price:200,
                    count:1
                },
                {
                    name:"蛋糕",
                    id:2,
                    images:'./images/img2.jpg',
                    price:20,
                    count:1
                },
                {
                    name:"烤鸡",
                    id:3,
                    images:'./images/img3.jpg',
                    price:500,
                    count:1
                },
                {
                    name:"蒜蓉大虾",
                    id:4,
                    images:'./images/img4.jpg',
                    price:199,
                    count:1
                },
            ],
            softDrink:['红酒','加多宝','可乐','雪碧','橙汁','椰汁','啤酒','苏打水','白酒','苹果醋','酸奶']
    }
    },
    methods:{
        decrement(index){
            this.barbecue[index].count--
        },
        increment(index){
            this.barbecue[index].count++
        },
        ermoveHandle(index){
            this.barbecue.splice(index,1)
        }
    },
    filters:{
        showPeice(price){
            return'￥'+price.toFixed(2)
        }
    },
    computed:{
        totalPrice(){
            let totalPrice=0
            for (let i = 0; i < this.barbecue; i++) {
                totalPrice +=this.barbecue[i].price*this.barbecue[i].count
            }
            return tolalPrice
        } 
    },
});